/*
Author:kermit
Email:455196886@qq.com
Company:http://dragontrail.com/
Creattime:2017-1-08
*/

//依赖jquery
var Components = function() {
	var  components = this;
	//头部幻灯片
	components.BannerSwiperInit = function(){
		var $bannerSwiper = $('#bannerSwiper'),
			$nextBtn = $bannerSwiper.find('.fleet-button-next'),
			$prevBtn = $bannerSwiper.find('.fleet-button-prev'),
			$pagination = $bannerSwiper.find('.swiper-pagination');
		components.bannerSwiper = new Swiper($bannerSwiper, {
			autoplay: 5000,
			pagination: $pagination,
			paginationClickable :true,
			prevButton:$prevBtn,
			nextButton:$nextBtn,
			paginationBulletRender: function (swiper, index, className) {
				var _index = (index + 1)>9?index+1:'0'+(index+1);
				return '<span class="' + className + '">' + _index + '</span>';
			}
		})
	}
	//相关短途体验
	components.ExpSwiperSwiperInit = function(){
		var $expSwiper = $('.com-exp-swiper'),
			$nextBtn = $expSwiper.parent('.com-exp-swiper-box').find('.exp-button-next'),
			$prevBtn = $expSwiper.parent('.com-exp-swiper-box').find('.exp-button-prev');
		components.expSwiper = new Swiper($expSwiper, {
			prevButton:$prevBtn,
			nextButton:$nextBtn,
			slidesPerView:2,
			breakpoints: {
		   		640:{
		   	   		slidesPerView: 1,
		   	 	}
			},
		})
	}
	//切换
	components.SwitchInit = function(){
		$('.nav-item').click(function(){
			var $this = $(this),
				index = $this.index(),
				$comSwitch = $this.parents('.com-switch'),
				$comSwitchContItem = $comSwitch.find('.content-item');
			$this.addClass('nav-item-active').siblings().removeClass('nav-item-active');
			$comSwitchContItem.eq(index).addClass('content-item-show').siblings().removeClass('content-item-show');
		});
	}
	//页面窗口变化
	components.WindowResize = function(){
		$(window).resize(function(event){

		});
	}
	components.Init = function() {
		components.BannerSwiperInit();
		components.ExpSwiperSwiperInit();
		components.SwitchInit();
		components.WindowResize();
		console.log('components init');
	}
}
var Components = new Components();
Components.Init();